package adv

import (
	"github.com/astaxie/beego/orm"
	"time"
)

type AdvType struct {
	Id int `orm:"pk;auto;description(主键)"`
	Tname string `orm:"size(30);description(广告位名称)"`
	Sort int `orm:"description(排序)"`
	Mark string `orm:"size(120);description(备注)"`
	IsActive int `orm:"default(1);description(1启用，0停用)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	CreateTime time.Time `orm:"auto_now;type(datetime);description(创建时间);null"`
	Adv []*Adv `orm:"reverse(many)"`

}

type Adv struct {
	Id int `orm:"pk;auto"`
	Title string `orm:"size(100);description(广告标题)"`
	Shortitle string `orm:"size(60);description(副标题)"`
	Pics string `orm:"size(200);description(封面图片)"`
	Url string `orm:"size(100);description(跳转地址)"`
	Mark string `orm:"size(200);description(备注)"`
	Sort int `orm:"description(排序)"`
	IsActive int `orm:"default(1);description(1启用，0停用)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	CreateTime time.Time `orm:"auto_now;type(datetime);description(创建时间);null"`
	AdvType *AdvType `orm:"rel(fk)"`

}

//广告位置表
func (a *AdvType) TableName() string {
	return "sys_adv_type"
}
//广告表
func (a *Adv) TableName() string {
	return "sys_adv"
}

func init()  {
	orm.RegisterModel(
		new(AdvType),
		new(Adv),
	)
}